﻿namespace AchSegítő.typeconverter
{
    using System;
    using System.Globalization;
    public class NullableUInt64Converter : NullableConverter<UInt64?>
    {
        private readonly UInt64Converter uint64Converter;

        public NullableUInt64Converter()
            : this(CultureInfo.InvariantCulture)
        {
        }

        public NullableUInt64Converter(IFormatProvider formatProvider)
        {
            uint64Converter = new UInt64Converter(formatProvider);
        }

        protected override bool InternalConvert(string value, out UInt64? result)
        {
            result = default(UInt64?);

            UInt64 innerConverterResult;
            if (!uint64Converter.TryConvert(value, out innerConverterResult)) return false;
            result = innerConverterResult;

            return true;
        }
    }
}
